Class IdeHead extends Box
var backButton;
var menuButton;
var menuBox;
function IdeHead(){
	this.set({size:["f",70],bg:["#f6f6f6",[,"#ccc"]]});
	this.addChild([
		[Button,{dim:"backButton",pos:[0,0,70,69],bg:"#f6f6f6",type:3},
			[{pos:["c","c",40,40],bg:[,["2#888"],"shape",[27,5],[10,20],[27,35]]}],
			[["我的测试"],{pos:[75,"c"]}]
		],
		[Button,{pos:["r-70",0,70,69],bg:"#f6f6f6",type:3},
			[{pos:["c","c",40,40],bg:[,["2#888"],"shape",[9,3],[34,21],[9,39],[9,3]]}],
		],
		[Button,{dim:"menuButton",pos:["r",0,70,70]},
			[{visible:false,pos:[0,0,"f","f"],bg:["#fff",[,,"#ccc"]]}],
			[{pos:["c","c",40,40],bg:[,["2#888"],"shape",[4,6],[36,6],0,[4,21],[36,21],0,[4,36],[36,36]]}],
		],
	]);
	G.stage.addListener(Evt.PRESS,this,this.onStagePress);
}
function popMenu(){
	if(this.menuBox){
		this.closeMenu();
		return;
	}
	this.menuButton.children[0].setVisible(true);
	var items=["外链","-","我的测试","-","新建","删除","分享"];
	var w=260;
	var body=new Box();
	var y=0;
	var checkIndex=2;
	for(var i=0;i<items.length;i++){
		var text=items[i];
		if(text=="-"){
			var cell=body.addChild([
				[{pos:[0,y,w,20]},
					[{pos:[65,"c",175,1],bg:"#ddd"}],
				]
			]);
		}
		else{
			cell=body.addChild([
				[Button,{id:i,name:"menuButton",type:2,pos:[0,y,w,50]},
					[{size:["f","f"]},
						{doif:checkIndex==i},
						[{pos:[12,12,24,24],bg:[,["2#444"],"shape",[2,12],[8,19],[21,2]]}],
						[[text,"#444",20],{pos:[65,"c"]}]
					],
					[{size:["f","f"],bg:"#39f"},
						{doif:checkIndex==i},
						[{pos:[12,12,24,24],bg:[,["2#fff"],"shape",[2,12],[8,19],[21,2]]}],
						[[text,"#fff",20],{pos:[65,"c"]}]
					],
				]
			]);
		}
		y+=cell.h;
	}
	var h=y;
	this.menuBox=this.addChild({pos:["r",69,260,h+2],bg:["#fff","#ccc"],shadow:[5,5,5,"#4000"]});
	this.menuBox.addChild([
		[{pos:["r",-1,69,2],bg:"#fff"}],
		[{pos:[0,0,50,"f"],bg:[["#fff","#f0f0f0",3],[,,,"#ddd"]]}],
		[body],
	]);
}
function closeMenu(){
	if(!this.menuBox) return;
	this.menuButton.children[0].setVisible(false);
	this.menuBox.remove();
	this.menuBox=null;
}
function onStagePress(){
	var isInMenu=this.menuBox&&this.menuBox.contains(G.target);
	if(G.target==this.menuButton){
		this.popMenu();
	}
	else if(!isInMenu){
		this.closeMenu();
	}
}